//
//  ZBMeChanpwdViewController.m
//  ZhiBo
//
//  Created by huangtie on 2017/11/8.
//  Copyright © 2017年 huangtie. All rights reserved.
//

#import "ZBMeChanpwdViewController.h"
#import "ZBLoginCell.h"

@interface ZBMeChanpwdViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic , strong) UITableView *tableView;

@property (nonatomic , strong) NSArray <ZBLoginCell *> *cells;

@end

@implementation ZBMeChanpwdViewController

+ (ZBMeChanpwdViewController *)launchInController:(UIViewController *)controller
{
    ZBMeChanpwdViewController *chanpwd = [[ZBMeChanpwdViewController alloc] init];
    if (controller) {
        [controller.navigationController pushViewController:chanpwd animated:YES];
    }
    return chanpwd;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"修改密码";
    
    ZBLoginCell *oldpwdCell = [[ZBLoginCell alloc] init];
    oldpwdCell.textField.placeholder = @"请输入原密码";
    [oldpwdCell.textField setSecureTextEntry:YES];
    
    ZBLoginCell *newpwdCell = [[ZBLoginCell alloc] init];
    newpwdCell.textField.placeholder = @"请输入新密码";
    [newpwdCell.textField setSecureTextEntry:YES];
    
    ZBLoginCell *newpwdVerifyCell = [[ZBLoginCell alloc] init];
    newpwdVerifyCell.textField.placeholder = @"验证新密码";
    [newpwdVerifyCell.textField setSecureTextEntry:YES];
    self.cells = @[oldpwdCell , newpwdCell , newpwdVerifyCell];
    
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    self.tableView.tableFooterView = [self footerView];
    self.tableView.tableHeaderView = [self headView];
    [self.view addSubview:self.tableView];
}

- (UIView *)headView{
    UIView *head = [[UIView alloc] init];
    head.size = CGSizeMake(SCREEN_WIDTH, 20);
    head.backgroundColor = [UIColor clearColor];
    return head;
}

- (UIView *)footerView
{
    UIView *footer = [[UIView alloc] init];
    footer.size = CGSizeMake(SCREEN_WIDTH, 65);
    footer.backgroundColor = [UIColor whiteColor];
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    loginBtn.size = CGSizeMake(footer.width - 140, footer.height - 20);
    loginBtn.centerX = footer.width / 2;
    loginBtn.centerY = footer.height / 2;
    loginBtn.backgroundColor = UICOLOR_ARGB(0xfffb3e3f);
    [loginBtn setTitle:@"修改密码" forState:UIControlStateNormal];
    [loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    loginBtn.titleLabel.font = FONT_NORMAL_14;
    loginBtn.layer.cornerRadius = loginBtn.height / 2;
    loginBtn.clipsToBounds = YES;
    [loginBtn addTarget:self action:@selector(doneClick) forControlEvents:UIControlEventTouchUpInside];
    [footer addSubview:loginBtn];
    return footer;
}

- (void)doneClick
{
    
}

#pragma mark DELEGATE-TABLEVIEW
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.cells.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return self.cells[indexPath.row];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return self.cells[indexPath.row].height;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return CGFLOAT_MIN;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return CGFLOAT_MIN;
}

@end
